package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * 积分商品
 * @author mycp
 */
@Setter @Getter
public class Product extends BaseDomain {
    public static final Integer STATE_NOMAL = 0; //上线
    public static final Integer STATE_DISABLE = 1; //下架

    private String productName;// 商品名

    private Long points;// 兑换积分

    private String coverUrl;// 商品封面

    private Integer state = STATE_NOMAL;// 商品状态

    private Long productcatalogId;// 所属商品分类
    private String productCatlogName;// 冗余数据,所属商品分类名称

    private Long sequence;// 商品序号

    private Long inventory;// 商品库存

    private Long conversionNum = 0L;// 商品兑换量

    private ProductContent content;// 商品详情

    public String getStateName(){
        String stateName = "上线";
        if (STATE_DISABLE.equals(state)){
            stateName = "下架";
        }
        return stateName;
    }


    public String getJson(){
        Map<String, Object> map = new HashMap<>();
        map.put("id", getId());
        map.put("productName", productName);
        map.put("points", points);
        map.put("coverUrl", coverUrl);
        map.put("state", state);
        map.put("productcatalogId", productcatalogId);
        map.put("sequence", sequence);
        map.put("inventory", inventory);
        map.put("conversionNum", conversionNum);
        return JSON.toJSONString(map);
    }

}